Repository navigation
Conversation
…rying it appwrite/appwrite#15510 (CLOUD-3RCB) fixed the server's NATS client writing into a pooled connection the broker had closed while it sat idle, which made the first publish after a broker rolling restart throw. The fix is entirely server-internal and changes no API this SDK exposes. What reaches a caller is the failure it caused, and still can in the narrower window upstream documents: queueing an async function run writes the execution row and only then publishes the job, so a failed publish answers `500 general_unknown` without saying whether the row was written. Retrying that blindly queues a second run of the function. createExecution() takes no caller-chosen execution ID, so createAsyncExecution() tags its attempt in the execution's path — which the server stores as `requestPath` — and asks listExecutions() what was recorded before deciding: retry when nothing carries the tag, and hand back the execution left behind when something does. - bump appwrite/appwrite to ^32.3.0 - tests/queue-restart.php drives both halves against the stub, which grew STUB_EXECUTIONS_FAIL and STUB_EXECUTIONS_RECORD_ON_FAILURE plus a recorded execution list to answer them Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🟢 Tier S · Ready to mergeThis change upgrades the PHP SDK and updates async execution handling to tag an attempt, inspect recorded executions after an ambiguous server error, and retry only when no matching execution is found. It also adds stub-server support and tests for both recorded and unrecorded failures, and documents the queued-work behavior.
📂 Walkthrough · 6
🔇 Filtered out · 1Findings Hansi considered but did not post.
Reviewed |
Member
|
the change doesn't make sense here since its an internal issue. how playground php is related ? @claudear |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cascade of appwrite/appwrite#15510 (CLOUD-3RCB).
What changed upstream
The fix is entirely inside the server's NATS client (
packages/nats/): a pooled connection to the broker that nothing had read since the broker closed it — during a rolling restart, where each node sendsINFO {"ldm":true}and then drops the sockets parked on it — was written into before anything read it, so the first publish after a restart threwConnectionException: Connection closed by server.Connection::settle()now processes whatever the broker already sent before any write-then-read path writes, and reconnects while that is still safe.No SDK API changed. Nothing in
packages/nats/maps to a generated service, model or enum inappwrite/appwrite(the composer package, which is the PHP SDK). I diffed the SDK between 32.2.0 and 32.3.0 to confirm: the only additions are the account-devices, Vipps OAuth, proxy-rule and WAF routes, none of which this playground calls.What reaches a caller
The failure the fix removes, which upstream's own "Known limitations" keeps possible in a narrower window. Queueing an async function run is two server-side steps —
Create.phpwrites the execution row with statuswaiting, then$publisherForFunctions->enqueue(...)publishes the job. Thatenqueueis uncaught in the route, so a throw folds intogeneral.php's default branch:500, typegeneral_unknown, messageServer Error. The caller cannot tell "nothing happened" from "the row exists and the job was lost".Retrying that blindly is what hurts: when the row was written, the retry queues a second run and the function does its work twice.
createExecution()takes no caller-chosen execution ID, so there is nothing to retry as. It does take the path the function is called on, and the server stores it — query string included — as the execution'srequestPath, whichlistExecutions()returns. SocreateAsyncExecution()tags its attempt there and asks what was recorded before deciding:ENQUEUE_ATTEMPTS);waitinglong afterwards lost its publish, and replacing it is a decision for the caller, not a retry.Anything below
500is an answer, not an ambiguity, and is still raised unchanged.Changes
composer.json:appwrite/appwrite^32.2.0→^32.3.0.playground.php:createAsyncExecution()tags and reconciles as above; newfindTaggedExecution()helper overlistExecutions().tests/queue-restart.php: runs the playground against a stub told to fail one async execution, once with the row recorded first and once without, asserting the request sequence each produces —create async, list, create async, getwhen nothing was recorded, andcreate async, list(no second run) when something was.tests/stub-server.php:STUB_EXECUTIONS_FAIL/STUB_EXECUTIONS_RECORD_ON_FAILURE, and the execution routes now record what they create so a list can be read back.counters()renamed tostate()now that it holds more than counts.tests/stub.php:Stub::start()takes extra environment for the server.README.md: a "Queued work" section.Verified
In a
php:8.5-clicontainer (local PHP is 8.4), withappwrite/appwriteresolving to 32.3.0:composer installclean,php -lover every file,composer testgreen — 21 playground calls over 26 requests, the 13 abuse-limit checks, and the 8 new ones.docker build .succeeds.findTaggedExecution()to always returnnullturns the second case intocreate async, list, create async, getand fails four assertions — i.e. the test does catch the double-queue it guards against.🤖 Generated with Claude Code